<template>
	<img :src="base64Src" v-bind="$attrs" v-on="$listeners"/>
</template>

<script>
	export default {
		name: 'image',
		props: {
			src: {
				type: String
			}
		},
		data() {
			const _this = this;
			return {
				originSrc: null, // 图片源地址
				base64Src: null // 图片base64
			}
		},
		watch: {
			src(val) {
				// 查找获取图片缓存
				this.toBase64Img(val);
			}
		},
		created() {
			this.toBase64Img(this.src);
		},
		
		methods:{
			toBase64Img(src){
				const _this = this;
				_this.originSrc = src;
				xwbridge.$utils.readFileAsDataURL({path:src}).then(res=>{
					_this.base64Src = res.data;
				});
			}
		}
	}
</script>

<style>
</style>